void chooser(U32* preComputationDepth)
{
	//Prompt user to choose his model (cube,octahedron,dodecahedron,icosahedron,tetrahedron)
	printf("\n\nWelcome Master. Please proceed to some decisions.\n\n");

	printf("***List of available polyhedrons : (default: 2)\n");
	printf("-----------------------------------------------\n");
	printf("1 - Tetrahedron\n");
	printf("2 - Cube\n");
	printf("3 - Octahedron\n");
	printf("4 - Dodecahedron\n");
	printf("5 - Icosahedron\n");
	printf("***Your choice master ? ");
	if(scanf_s("%d",&settings.polyhedronType)!=1 || settings.polyhedronType < 1 || settings.polyhedronType > 5)
	{
		printf("Invalid choice. Using default\n");
		settings.polyhedronType = 2;
	}
	printf("\n\n");


	printf("***List of available computation methods : (default: 1)\n");
	printf("-------------------------------------------------------\n");
	printf("1 - Recursive with memory\n");
	printf("2 - Recursive without memory\n");
	printf("***Your choice master ? ");
	if(scanf_s("%d",&settings.computationMethod)!=1 || settings.computationMethod < 1 || settings.computationMethod > 2)
	{
		printf("Invalid choice. Using default\n");
		settings.computationMethod = 1;
	}
	printf("\n\n");


	printf("***Computation depth master ? (1-20, default: 10)\n");
	printf("-------------------------------------------------\n");
	if(scanf_s("%d",&settings.maximumRecursion)!=1 || settings.maximumRecursion < 1 || settings.maximumRecursion > 20)
	{
		printf("Invalid choice. Using default\n");
		settings.maximumRecursion = 10;
	}
	printf("\n\n");

	
	printf("***Pre-computation depth master ? (1-6, default: 4)\n");
	printf("---------------------------------------------------\n");
	if(scanf_s("%d",preComputationDepth)!=1 || *preComputationDepth < 1 || *preComputationDepth> settings.maximumRecursion || *preComputationDepth>6)
	{
		printf("Invalid choice. Using default\n");
		*preComputationDepth = 4;
	}
	printf("\n\n");

	settings.maximumRecursion -= *preComputationDepth;
}

void printResults(U32 preComputationDepth, double computationTime, double* computationTimeArray, U32 nbMaggots, U32 nbComputatedCubes)
{
	double totalTime = 0.0;
	double efficacity = 0.0;
	for (U32 i = 1; i<= nbMaggots; i++)
	{
		totalTime += computationTimeArray[i];
	}
	efficacity = totalTime / (double)nbMaggots;
	efficacity /= computationTime;

	printf("\t==================================================================================\n");
	printf("\t| Polyhedron: ");
	switch(settings.polyhedronType)
	{
	case POLY_TETRAHEDRON:
		printf("Tetrahedron  ");
		break;

	case POLY_CUBE:
		printf("Cube         ");
		break;

	case POLY_OCTAHEDRON:
		printf("Octahedron   ");
		break;

	case POLY_DODECAHEDRON:
		printf("Dodecahedron ");
		break;

	case POLY_ICOSAHEDRON:
		printf("Icosahedron  ");
		break;
	}
	printf("| Nodes: %d | Recursion: %2d | Initial: %2d | Method: %d |\n",nbMaggots,settings.maximumRecursion + preComputationDepth,preComputationDepth,settings.computationMethod);
	printf("\t==================================================================================\n\n");

	printf("\tAdherence test calls   :   %lld\n",calls);
	printf("\tProcessed cubes        :   %d\n",nbComputatedCubes);
	printf("\tUnitary cube edge      :   %.10lf\n",FP2FLOAT(FP_ONE >> (settings.maximumRecursion + preComputationDepth)));
	printf("\tTotal computation time :   %.2lf s\n",computationTime);
	printf("\tYour volume is between :   %.10lf\n",FP2FLOAT(currentSum));
	printf("\t                   and :   %.10lf\n",FP2FLOAT(currentSum+currentError));
	printf("\tMargin of error        :   %.10lf \n",FP2FLOAT(currentError));
	printf("\tEfficiency             :   %.2lf %% \n",efficacity*100.0);
	printf("\tAverage time per cube  :   %.4lf s \n",totalTime/(double)nbComputatedCubes);

	printf("\n\t==================================================================================\n\n");

}

void logResults(U32 preComputationDepth, double computationTime, double* computationTimeArray, U32 nbMaggots, U32 nbComputatedCubes)
{
	CHAR filename[64];
	CHAR polyName[16];
	double totalTime = 0.0;
	double efficacity = 0.0;
	FILE* f;

	switch(settings.polyhedronType)
	{
	case POLY_TETRAHEDRON:
		sprintf(polyName,"Tetrahedron__");
		break;

	case POLY_CUBE:
		sprintf(polyName,"Cube_________");
		break;

	case POLY_OCTAHEDRON:
		sprintf(polyName,"Octahedron___");
		break;

	case POLY_DODECAHEDRON:
		sprintf(polyName,"Dodecahedron_");
		break;

	case POLY_ICOSAHEDRON:
		sprintf(polyName,"Icosahedron__");
		break;
	}

	sprintf(filename,"%s%02d-%02d-%02d-%02d.txt",polyName,nbMaggots,settings.maximumRecursion + preComputationDepth,preComputationDepth,settings.computationMethod);
	f = fopen(filename,"a+");

	if (f == NULL)
	{
		return;
	}


	for (U32 i = 1; i<= nbMaggots; i++)
	{
		totalTime += computationTimeArray[i];
	}
	efficacity = totalTime / (double)nbMaggots;
	efficacity /= computationTime;

	fprintf(f,"==================================================================================\n");
	fprintf(f,"| Polyhedron: ");
	switch(settings.polyhedronType)
	{
	case POLY_TETRAHEDRON:
		fprintf(f,"Tetrahedron  ");
		break;

	case POLY_CUBE:
		fprintf(f,"Cube         ");
		break;

	case POLY_OCTAHEDRON:
		fprintf(f,"Octahedron   ");
		break;

	case POLY_DODECAHEDRON:
		fprintf(f,"Dodecahedron ");
		break;

	case POLY_ICOSAHEDRON:
		fprintf(f,"Icosahedron  ");
		break;
	}	
	fprintf(f,"| Nodes: %d | Recursion: %2d | Initial: %2d | Method: %d |\n",nbMaggots,settings.maximumRecursion + preComputationDepth,preComputationDepth,settings.computationMethod);
	fprintf(f,"==================================================================================\n\n");

	fprintf(f,"Adherence test calls   :   %lld\n",calls);
	fprintf(f,"Processed cubes        :   %d\n",nbComputatedCubes);
	fprintf(f,"Unitary cube edge      :   %.10lf\n",FP2FLOAT(FP_ONE >> (settings.maximumRecursion + preComputationDepth)));
	fprintf(f,"Total computation time :   %.2lf s\n",computationTime);
	fprintf(f,"Your volume is between :   %.10lf\n",FP2FLOAT(currentSum));
	fprintf(f,"                   and :   %.10lf\n",FP2FLOAT(currentSum+currentError));
	fprintf(f,"Margin of error        :   %.10lf \n",FP2FLOAT(currentError));
	fprintf(f,"Efficiency             :   %.2lf %% \n",efficacity*100.0);
	fprintf(f,"Average time per cube  :   %.4lf s \n",totalTime/(double)nbComputatedCubes);

	fprintf(f,"\n==================================================================================\n\n");

	fclose(f);

}